Component({
  properties: {
    direction: {
      type: 'String',
      value: 'start'
    },

    info: {
      type: Object,
      value: {},

      observer(val) {
        if (val.type === 'code') {
          this.setData({
            code: '```js\r\n' + val.content + '\r\n```'
          })
        }
      }
    }
  },

  data: {
    code: ''
  },

  methods: {
    handleSelect(e) {
      this.triggerEvent('select', {
        info: e.currentTarget.dataset.info
      })
    },

    handleViewImage(e) {
      wx.previewImage({
        urls: [e.currentTarget.dataset.url],
      })
    }
  }

})